package com.example.gulimall.order.web;

import com.alipay.api.AlipayApiException;
import com.example.gulimall.order.alipay.AlipayTemplate;
import com.example.gulimall.order.service.OrderService;
import com.example.gulimall.order.vo.PayVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class PayWebController {
    @Autowired
    AlipayTemplate alipayTemplate;
    @Autowired
    OrderService orderService;
    public String aliPayOrder(@RequestParam("orderSn") String orderSn) throws AlipayApiException {
        System.out.println("接收到要支付的订单号为"+orderSn);
        PayVo payVo =orderService.getOrderPayVo(orderSn);
        String pay = alipayTemplate.pay(payVo);
        return pay;
    }
}
